//edit页面使用begin ===========================================================
var params = {};
var current = {};
var defaultPageSize = 10;
var currentPage = 1;
var pageSize = defaultPageSize;
var option = {};

// 编辑入口
$(function() {
	var id = localStorage.getItem("rowId");
	localStorage.removeItem("rowId");
	getEntityById(id);
	$('.add').on('click', updateEntity);
	$('.empty').on('click', cancel);
});

var seq = 1;
function getEntityById(id) {
	var valueTable = document.getElementById("fixedThead");
	var table_tr = valueTable.getElementsByTagName('tr');
	seq = table_tr.length;
	$
			.ajax({
				url : webUrl + 'lookup/getEntityById.do',
				type : 'post',
				data : {
					id : id
				}
			})
			.done(
					function(data) {
						var d = data.bo;
						// 初始化
						$("#id").val(d.sysLookupType.id);
						if (d.sysLookupType.lookupType != null) {
							$("#lookupType").val(d.sysLookupType.lookupType);
						}
						if (d.sysLookupType.lookupMeaning != null) {
							$("#lookupMeaning").val(
									d.sysLookupType.lookupMeaning);
						}
						if (d.sysLookupType.remark != null) {
							$("#remark").val(d.sysLookupType.remark);
						}
						if (d.sysLookupValue !== null
								&& d.sysLookupValue !== undefined
								&& d.sysLookupValue !== '') {
							for (var i = d.sysLookupValue.length - 1; i >= 0; i--) {
								// alert(JSON.stringify(d.sysLookupValue[i].id));
								var tbl = document.getElementById("fixedThead");
								var rowSize = tbl.rows.length;
								var row = tbl.insertRow(rowSize);
								var cell0 = row.insertCell(0);
								var cell1 = row.insertCell(1);
								var cell2 = row.insertCell(2);
								var cell3 = row.insertCell(3);
								var cell4 = row.insertCell(4);
								cell0.innerHTML = "<input type='checkbox' name='checkLines' style='width:20px'/>";
								cell1.innerHTML = seq;
								cell2.innerHTML = "<input name='lookupCode_"
										+ seq + "' id='lookupCode_" + seq
										+ "' style='width:150px' value='"
										+ d.sysLookupValue[i].lookupCode
										+ "'/>"
								cell3.innerHTML = "<input name='lookupName_"
										+ seq + "' id='lookupName_" + seq
										+ "' style='width:150px' value='"
										+ d.sysLookupValue[i].lookupName
										+ "'/>"
								cell4.innerHTML = "<input name='remark_" + seq
										+ "' id='remark_" + seq
										+ "' style='width:200px' value='"
										+ d.sysLookupValue[i].remark + "'/>"
								// <input type='hidden' id='id' value='" +
								// d.sysLookupValue[i].id + "'></input>
								seq++;
							}
						}
					});
}
function cancel() {
	$('.main_panel').load(webUrl + "public/page/lookup/query.html");
}
// edit页面使用end =============================================================
